package com.wds.stock.stockana.requests;

import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonArrayRequest;
import com.wds.stock.stockana.constants.NetWorkConstants;
import com.wds.stock.stockana.events.GetAllStocksEvent;

import org.json.JSONArray;

import de.greenrobot.event.EventBus;

/**
 * ---------------------------------------------------
 * Description: 获取所有stock的请求类
 * Author: ljgsonx
 * Belong to: com.wds.stock.stockana.requests
 * Time: 2016/1/15 17:42
 * ---------------------------------------------------
 */
public class GetAllStocks extends JsonArrayRequest {

    public GetAllStocks(){
        super(Method.GET, NetWorkConstants.GET_ALLINVOICES_URL, listener, errorListener);
    }

    static Response.Listener<JSONArray> listener = new Response.Listener<JSONArray>(){

        @Override
        public void onResponse(JSONArray response) {
            EventBus.getDefault().post(new GetAllStocksEvent(response.toString()));
        }
    };

    static Response.ErrorListener errorListener = new Response.ErrorListener(){

        @Override
        public void onErrorResponse(VolleyError error) {
            System.out.println(error.toString());
        }
    };

}
